package com.dotflat.agreement.domain;

import com.dotflat.rest.domain.AreableObjectBase;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data;
import lombok.EqualsAndHashCode;

import javax.persistence.*;
import java.util.List;

@Entity
@Table(name = "op_agreement")
@Data
@EqualsAndHashCode(callSuper = true)
public class OPAgreement extends AreableObjectBase {

	@Column(columnDefinition = "longtext  COMMENT '协议标题'")
	private String title = "";

	@Column(columnDefinition = "longtext  COMMENT '可能的内容'")
	private String content="";

	@Column( name = "static_url", columnDefinition = "varchar(512) COMMENT '持久化文件'")
	private String staticUrl;

	@Column(columnDefinition = "varchar(512) COMMENT '封面'")
	private String cover;

	@Column(columnDefinition = " bit(1) DEFAULT 0 COMMENT '生效' ", nullable = false)
	public Integer valid = 1;

//	@Column(columnDefinition = "varchar(64) COMMENT '模板id'")
//	private String templateId;
//	@Column(columnDefinition = "varchar(32) COMMENT '班级id'")
//	private String classId;
	@OneToMany(fetch = FetchType.LAZY, mappedBy = "agreement")
	@OrderBy("created DESC")
	@JsonIgnore
	private List<OPAgreementRecord> records;

}
